// pages/my/exchangerecord/exchangerecord.js
Page({
  data: {
    active: 0,
    list: [],
    page: 1,
    size: 10,
    isNoMore: true,
    isLoding: true
  },
  onLoad: function (options) {
    this.getData();
  },
  tab(e) {
    this.setData({
      active: e.detail.index,
      list: [],
      page: 1,
      isNoMore: true,
      isLoding: true
    });
    this.getData();
  },
  onPullDownRefresh: function () {
    this.getData();
  },
  onReachBottom() {
    if (this.data.isNoMore) {
      this.setData({
        page: this.data.page / 1 + 1,
        isLoding: false
      });
      this.getData();
    }
  },
  getData() {
    getApp().globalData.http.exchangeGoodRecord({
      status: this.data.active
    }).then(res => {
      let data_tmp = [...this.data.list, ...res.data];
      this.setData({
        list: data_tmp,
        isLoding: true
      });
      if (this.data.list.length == res.count) {
        this.setData({
          isNoMore: false
        });
      }
      wx.stopPullDownRefresh();
      wx.hideNavigationBarLoading();
    });
  }
})